package com.zcf.pojo;

import com.baomidou.mybatisplus.enums.IdType;

import java.util.Date;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.activerecord.Model;
import lombok.Data;

import javax.websocket.Session;


import java.io.Serializable;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 
 * </p>
 *
 * @author ZhaoQi
 * @since 2019-02-21
 */
@Data
public class UserBean extends Model<UserBean> implements Serializable{

    private static final long serialVersionUID = 1L;

    @TableId(value = "id", type = IdType.AUTO)
    private Long id;
    private String phone;
    private String wxname;
    private String wximg;
    private Date createtime;
    /**
     * 金币
     */
    private Integer money;
    /**
     * 账号状态 0正常 1冻结     游戏中3表示为机器人
     */
    private Integer state;
    /**
     * 是否充值过  0未充值  1已充值
     */
    @TableField("isPay")
    private Integer isPay;
    /**
     * 用户类型  0观战  1参战 3退出
     */
    private Integer type=-1;
    /**
     * 是否已登录
     */
    @TableField("isLogin")
    private Integer isLogin;

    /**
     * 倍数(临时)
     */
    @TableField(exist = false)
    private Integer multiple;
    /**
     * 是否亮牌
     */
    @TableField(exist = false)
    private Integer openCards = -1;
    //游戏存储属性
    /**
     * 用户session 用户推送消息
     */
    @TableField(exist = false)
    private Session session;
    /**
     * 用户牌面
     */
    @TableField(exist = false)
    private List<Integer> userCards;
    /**
     * 是否已准备
     */
    @TableField(exist = false)
    private Integer isReady=0;
    /**
     * 是否是庄家
     * 1申请上庄玩家
     * 2抢庄玩家
     * 3不抢
     */
    @TableField(exist = false)
    private int isOwner=-1;
    /**
     * 玩家位置
     */
    @TableField(exist = false)
    private Integer position=-1;
    /**
     * 输赢情况  0输  1和  2赢
     */
    @TableField(exist = false)
    private Integer bunko;
    /**
     * 下注情况
     */
    @TableField(exist = false)
    private Map<Integer, Integer> betList;
    /**
     * 总输赢情况
     */
    @TableField(exist = false)
    private int winNumber;
    /**
     * 牌型
     */
    @TableField(exist = false)
    private int cardType;
    /**
     * 推注人、注数
     */
    @TableField(exist = false)
    private Object[] bolus;
    @TableField(exist = false)
    private int changecard = -1;
    private Integer sex ;
    @TableField(exist = false)
    private Integer integral;
    /**
     * 赢的总钱数
     */
    @TableField(exist = false)
    private int sumWinnumber = 0;
    /**
     * 操作状态
     */
    private int opentionType;
    /**
     * 是否开启检测线程
     */
    private  Integer isThread=30;
    /**
     * 总价
     */
    private int total;

    /**
     * 心跳
     */
    private  int xt=10;
    @Override
    protected Serializable pkVal() {
        return this.id;
    }

    public UserBean getCustom(){
        UserBean user = new UserBean();
        user.setId(this.id);
        user.setWxname(this.wxname);
        user.setPhone(this.phone);
        user.setState(this.state);
        user.setIsPay(this.isPay);
        user.setType(this.type);
        user.setIsLogin(this.isLogin);
        user.setWximg(this.wximg);
        user.setCreatetime(this.createtime);
        user.setMoney(this.money);
        user.setWinNumber(this.winNumber);
        user.setUserCards(this.userCards);
        user.setIsReady(this.isReady);
        user.setIsOwner(this.isOwner);
        user.setPosition(this.position);
        user.setBunko(this.bunko);
        user.setBetList(this.betList);
        return user;
    }




    
    public Map<String, Object> returnMap(Map<String, Object> data, String string){
    	String[] strs = string.split("-");
    	for (String str : strs) {
			if(str.equals("user")){
				data.put("user", getCustom());
			}
			if(str.equals("userType")){
				data.put("userType", this.type);
			}
			if(str.equals("userid")){
				data.put("usreid", this.id);
			}
			if(str.equals("usercards")){
				data.put("usercards",this.userCards);
			}
			if(str.equals("money")){
				data.put("money", this.money);
			}
			if(str.equals("userBets")){
				data.put("userBets", this.winNumber);
			}
			if(str.equals("userid")){
				data.put("userid", this.id);
			}
			if(str.equals("userimg")){
				data.put("userimg", this.wximg);
			}
			if(str.equals("userName")){
				data.put("userName", this.wxname);
			}
		}
    	
    	return data;
    }

    
    
}
